home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
cstdio.arc
/
SRC.ARC
/
LMOVE.A
< prev
next >
Wrap
Text File
|
1984-12-27
|
1KB
|
67 lines
; lmove.a - intersegment move.
; (C) Copyright 1984 Cray Research Inc. - All Rights Reserved.
; G. R. Mansfield. 84/12/26.
; Ver 1.0-4C27.
cseg
public _lmove_
; lmove(count, s, sseg, d, dseg) /* intersegment move */
; SEGSIZE count; /* number of bytes to move */
; BYTE *s, *d; /* source, destination offsets */
; SEGBASE sseg, dseg; /* source, destination segments */
_lmove_:
mov bx,sp
mov cx,[bx+2] ; count
jcxz lmv3 ; if nothing to move
mov si,[bx+4] ; source offset
mov ax,[bx+6] ; source segment
mov di,[bx+8] ; destination offset
mov bx,[bx+10] ; destination segment
push ds
push es
mov ds,ax ; ax = abcd
mov es,bx
push cx ; compare effective addresses
mov cx,4
rol ax,cl ; ax = bcda
rol bx,cl
mov dh,al ; dh = da; upper 4 of 20-bit address
mov dl,bl
and dx,00F0Fh ; dh = 0a
xor al,dh ; ax = bcd0
xor bl,dl
add ax,si ; ax = bcd0 + ABCD; 20-bit address
adc dh,ch ; dh,ax = 0abcd0 + ABCD; (ch = 0)
add bx,di
adc dl,ch
sub dh,dl ; destination - source
sbb ax,bx
pop cx
jz lmv2 ; if null move
ja lmv4 ; if (source > destination), no overlap
std ; move from end of region
add si,cx
add di,cx
dec si
dec di
shr cx,1
jnb lmv1 ; move byte if necessary
movsb
lmv1: dec si
dec di
repz movsw
cld
lmv2: pop ds
pop es
lmv3: ret
lmv4: shr cx,1 ; move from start of region
repz movsw
jnb lmv2 ; move remaining byte
movsb
jmp lmv2